home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-22 | 3.7 KB | 147 lines | [TEXT/CWIE] |
- unit MyListManager;
-
- interface
-
- uses
- Lists;
-
- function LCountSelections (list: ListHandle): integer;
- function LHasSelection (list: ListHandle): boolean;
- procedure LSetSingleSelection (list: ListHandle; v: integer);
- function LPointToCell (list: ListHandle; pt: Point; var c: cell): boolean;
- function LGetFirstSelection (list: ListHandle; var c: cell): boolean;
- function LGetLastSelection (list: ListHandle; var c: cell): boolean;
- function LClickSafe(localPt:Point; modifiers:integer; theList:ListRef):boolean;
-
- implementation
-
- uses
- OSUtils, Traps;
-
- function LCountSelections (list: ListHandle): integer;
- var
- c: Cell;
- count: integer;
- begin
- count := 0;
- c.h := 0;
- c.v := 0;
- while LGetSelect(true, c, list) do begin
- count := count + 1;
- c.v := c.v + 1;
- end;
- LCountSelections := count;
- end;
-
- function LHasSelection (list: ListHandle): boolean;
- var
- c: Cell;
- begin
- c.h := 0;
- c.v := 0;
- LHasSelection := LGetSelect(true, c, list);
- end;
-
- procedure LSetSingleSelection (list: ListHandle; v: integer);
- var
- c: Cell;
- begin
- c.h := 0;
- c.v := v;
- LSetSelect(true, c, list);
- c.v := 0;
- c.h := 0;
- while LGetSelect(true, c, list) do begin
- if c.v <> v then begin
- LSetSelect(false, c, list);
- end;
- c.v := c.v + 1;
- c.h := 0;
- end;
- end;
-
- function LPointToCell (list: ListHandle; pt: Point; var c: cell): boolean;
- begin
- c.h := 0;
- c.v := -1;
- if PtInRect(pt, list^^.rView) then begin
- c.v := list^^.visible.top + (pt.v - list^^.rView.top) div list^^.cellSize.v;
- end;
- LPointToCell := PtInRect(c, list^^.dataBounds);
- end;
-
- function LGetLastSelection (list: ListHandle; var c: cell): boolean;
- var
- tmp: integer;
- begin
- LGetLastSelection := false;
- c.h := 0;
- c.v := 0;
- while LGetSelect(true, c, list) do begin
- LGetLastSelection := true;
- tmp := c.v;
- c.v := c.v + 1;
- end;
- c.v := tmp;
- end;
-
- function LGetFirstSelection (list: ListHandle; var c: cell): boolean;
- begin
- c.h := 0;
- c.v := 0;
- LGetFirstSelection := LGetSelect(true, c, list);
- end;
-
- {
- ----------------------------------------------------------------------------
- LClickPPCSafe
-
- Process a mouse-down in a list.
-
- Entry: localPt = click location in local coords.
- modifiers = keyboard modifiers from event record.
- theList = handle to list record.
-
- Exit: function result = true if double-click.
-
- This function is identical to the standard LClick function, except
- it contains a hack by Dave Radcliffe of Apple DTS to solve a
- problem with clickloop functions in native mode. The problem is
- that the 68K List Manager expects the Boolean function
- result in the Z bit in the condition code register, but the Mixed
- Mode Manager doesn't set this bit correctly. The hack uses a 68K
- wrapper in native mode to set the Z bit.
- ----------------------------------------------------------------------------
- }
-
- function LClickSafe(localPt:Point; modifiers:integer; theList:ListRef):boolean;
- var
- clickLoop68K : packed record
- move:longInt;
- jsr:integer;
- tst:integer;
- rts:integer;
- clickLoopUPP:ListClickLoopUPP;
- end;
- begin
- if theList^^.lClickLoop = nil then begin
- LClickSafe := LClick(localPt, modifiers, theList);
- end else begin
- clickLoop68K.move := $207A0008;
- clickLoop68K.jsr := $4E90;
- clickLoop68K.tst := $4A00;
- clickLoop68K.jsr := $4E75;
- clickLoop68K.clickLoopUPP := theList^^.lClickLoop;
- {$IFC not GENERATINGPOWERPC}
- if NGetTrapAddress(_HWPriv, OSTrap) <> NGetTrapAddress(_Unimplemented, ToolTrap) then begin
- FlushDataCache;
- FlushInstructionCache;
- end;
- {$ENDC}
- theList^^.lClickLoop := @clickLoop68K;
- LClickSafe := LClick(localPt, modifiers, theList);
- theList^^.lClickLoop := clickLoop68K.clickLoopUPP;
- end;
- end;
-
- end.